package com.example.demo.controller;

import com.example.demo.entity.Paper;
import com.example.demo.service.PaperService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags="试卷管理")
@RequestMapping(path = "/paper")
@RestController
public class PaperController {
    @Autowired
    private PaperService service;

    @ApiOperation("获取试卷")
    @RequestMapping(path="/get",method = RequestMethod.GET)
    public List<Paper> get_paper(@RequestBody String subject){
        return service.get(subject);
    }

    @ApiOperation("保存试卷")
    @RequestMapping(path="/save",method = RequestMethod.POST)
    public void save_paper(@RequestBody Paper paper){
        service.save(paper);
    }

    @ApiOperation("删除试卷")
    @RequestMapping(path = "/delete",method = RequestMethod.POST)
    public void delete_paper(Integer id){
        service.delete(id);
    }

    @ApiOperation("修改试卷")
    @RequestMapping(path="/edit",method = RequestMethod.POST)
    public void delete_paper(@RequestBody Paper paper){
        service.update(paper);
    }
}
